<template>
    <!-- 对话框表单 -->
    <!-- 建议使用 Prettier 格式化代码 -->
    <!-- el-form 内可以混用 el-form-item、FormItem、ba-input 等输入组件 -->
    <el-dialog
        class="ba-operate-dialog"
        :close-on-click-modal="false"
        :model-value="['check'].includes(baTable.form.operate!)"
        @close="baTable.toggleForm"
        width="700px"
    >
        <template #header>
            <div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
                {{ t('驳回房源信息') }}
            </div>
        </template>
        <el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
            <div class="show-info" :class="'ba-' + baTable.form.operate + '-form'">
                <el-alert title="驳回后此信息无法上架，需要用户重新上传" type="warning" show-icon :closable="false" />
                <el-row style="background: rgb(246, 248, 250); border-radius: 5px; padding: 10px">
                    <el-input
                        v-model="checkForm.check"
                        style="width: 650px"
                        :rows="4" maxlength="200"
                        show-word-limit
                        type="textarea"
                        placeholder="请输入"
                    />
                </el-row>
            </div>
        </el-scrollbar>
        <template #footer>
            <div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
                <el-button @click="baTable.toggleForm()">{{ t('Cancel') }}</el-button>
                <el-button @click="confirmClick()" v-blur :loading="baTable.form.submitLoading"  type="primary">
                    {{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('提交') }}
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>
<script setup lang="ts">
import type { DrawerProps } from 'element-plus'
import { inject, reactive, ref } from 'vue'
const drawer = ref(true)
const direction = ref<DrawerProps['direction']>('rtl')
const radio1 = ref('Option 1')

import Check from './check.vue'
import { checkSumit } from '/@/api/backend/hourse'
import { useConfig } from '/@/stores/config'
import type baTableClass from '/@/utils/baTable'
import { buildValidatorData } from '/@/utils/validate'
import { ElNotification } from 'element-plus'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const config = useConfig()

const baTable = inject('baTable') as baTableClass
const handleClose = (done: () => void) => {}

const checkForm= reactive({
  check_mark: '',
  id: '',
  submitLoading: false,
})


function cancelClick() {}
function confirmClick() {
    baTable.form.submitLoading = true
    checkForm.id=baTable.table.extend!.infoData.id
    checkForm.check_mark=checkForm.check
    checkSumit(checkForm).then((result) => {
        baTable.form.submitLoading = false
        checkForm.check_mark=''
        checkForm.id=''
        baTable.form.operate! = ''
        ElNotification({
                title: '',
                message: result.msg,
                type: 'success',
            })
        setTimeout(() => {
            baTable.getIndex()
        }, 2000);
    }).catch((err) => {
        baTable.form.submitLoading = false
    });
}
</script>
<style scoped>
.show-info{
    .el-row {
  margin-bottom: 20px;
}
    .label-title{color: #b1b3b4;}
}
</style>